package com.ruoyi.system.api;

import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.domain.SysDept;
import com.ruoyi.system.api.factory.RemoteUserFallbackFactory;
import feign.Headers;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(contextId = "remoteDeptService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)

public interface RemoteDeptService {
    /**
     * 新增部门
     */
    @PostMapping("/dept")
    public R<Object> insert(@RequestBody SysDept dept, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
    
    @GetMapping("/dept/{deptId}")
    public R<SysDept> getInfo(@PathVariable("deptId") Long deptId);
    
    @PutMapping("/dept")
    public R<Integer> edit(@RequestBody SysDept dept);

    /**
     * 获取包含当前用户所在部门的上级
     * @return
     */
    @GetMapping("/dept/selectDeptIdsByDeptId/{userId}")
    public List<Long> selectDeptIdsByDeptId(@PathVariable("userId") Long userId);

    @GetMapping("/dept/searchByDeptName/{deptName}")
    Long searchByDeptName(@PathVariable("deptName") String deptName);
}
